import request from '@/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/blade-iot/product/version/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const getDetail = (id) => {
  return request({
    url: '/blade-iot/product/version/detail',
    method: 'get',
    params: {
      id
    }
  })
}

export const remove = (ids) => {
  return request({
    url: '/blade-iot/product/version/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/blade-iot/product/version/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/blade-iot/product/version/submit',
    method: 'post',
    data: row
  })
}

export const select = (productId) => {
  return request({
    url: '/blade-iot/product/version/select',
    method: 'get',
    params: {
      productId
    }
  })
}

export const dataPublishedTsl = (productId, blockId) => {
  return request({
    url: '/blade-iot/product/version/data-published-tsl',
    method: 'get',
    params: {
      productId,
      blockId
    }
  })
}

export const dataDraftedTsl = (productId, blockId) => {
  return request({
    url: '/blade-iot/product/version/data-drafted-tsl',
    method: 'get',
    params: {
      productId,
      blockId
    }
  })
}

export const dataPublished = (productId) => {
  return request({
    url: '/blade-iot/product/version/data-published',
    method: 'get',
    params: {
      productId
    }
  })
}

export const dataPublishedByKey = (productKey) => {
  return request({
    url: '/blade-iot/product/version/data-published-by-key',
    method: 'get',
    params: {
      productKey
    }
  })
}

export const dataSnapshot = (versionId) => {
  return request({
    url: '/blade-iot/product/version/data-snapshot',
    method: 'get',
    params: {
      versionId
    }
  })
}

export const dataRecovery = (versionId) => {
  return request({
    url: '/blade-iot/product/version/data-recovery',
    method: 'post',
    params: {
      versionId
    }
  })
}

export const dataImport = (versionId, productId) => {
  return request({
    url: '/blade-iot/product/version/data-import',
    method: 'post',
    params: {
      versionId,
      productId
    }
  })
}
